﻿<Window x:Class="Microsoft.Samples.Kinect.BasicInteractions.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Microsoft.Samples.Kinect.BasicInteractions" Background="White"
        Title="Kinect News" Closing="MainWindow_Closing" WindowStyle="None" WindowState="Maximized" Icon="/BasicInteractions-WPF;component/Icon.ico">
    <Window.Resources>
        <Storyboard x:Key="HideContent">
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetProperty="(UserControl.RenderTransform).(ScaleTransform.ScaleX)">
                <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0.1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames
                Storyboard.TargetProperty="(UserControl.RenderTransform).(ScaleTransform.ScaleY)">
                <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0.1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
                <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0" />
            </DoubleAnimationUsingKeyFrames>

        </Storyboard>
        <Storyboard x:Key="ShowContent">
            <DoubleAnimation Storyboard.TargetProperty="(UserControl.RenderTransform).(ScaleTransform.ScaleX)"
                             From="0.1" To="1" Duration="0:0:0.5" />
            <DoubleAnimation Storyboard.TargetProperty="(UserControl.RenderTransform).(ScaleTransform.ScaleY)"
                             From="0.1" To="1" Duration="0:0:0.5" />
            <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="00:00:0.5" />
        </Storyboard>
    </Window.Resources>

    <Grid>
        <Viewbox>
            <Grid Width="1920" Height="1080">
                <Grid
                Visibility="{Binding Controller.HasActiveSkeleton, Source={x:Static Application.Current}, FallbackValue={x:Static Visibility.Hidden}, Converter={StaticResource VisibilityConverter}}">

                    <local:CategorySelectionControl x:Name="CategorySelection"
                                                Categories="{Binding Categories}" Visibility="Hidden"/>

                    <local:Introduction x:Name="IntroScreen" Opacity="0" Visibility="Collapsed"/>

                    <Border BorderBrush="#A7A9AC" BorderThickness="1" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,0,118,0" >
                        <Image Height="88" Width="118" Source="{Binding Path=Controller.Silhouette, Source={x:Static Application.Current}}" Stretch="Uniform" IsHitTestVisible="False">
                            <Image.Style>
                                <Style TargetType="{x:Type Image}">
                                    <Setter Property="Opacity" Value="0" />
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ElementName=IntroScreen, Path=IsHandRaised}" Value="False">
                                            <DataTrigger.EnterActions>
                                                <BeginStoryboard Storyboard="{StaticResource HideContent}" />
                                            </DataTrigger.EnterActions>
                                            <DataTrigger.ExitActions>
                                                <BeginStoryboard Storyboard="{StaticResource ShowContent}" />
                                            </DataTrigger.ExitActions>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Image.Style>
                        </Image>
                    </Border>

                    <local:VoiceInstructionControl x:Name="VUI" VerticalAlignment="Top"
                                  local:KinectController.PreviewHandEnter="OnVuiPreviewHandEnter" />
                </Grid>

                <local:AttractControl x:Name="AttractContent" ItemsSource="{Binding Categories}" IsHitTestVisible="False"
                                  SelectedItemChanged="AttractControl_SelectedItemChanged">
                </local:AttractControl>

                <Image Source="{Binding Path=Controller.Silhouette, Source={x:Static Application.Current}}" Stretch="Uniform" IsHitTestVisible="False">
                    <Image.Style>
                        <Style TargetType="{x:Type Image}">
                            <Setter Property="Opacity" Value="0" />
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ElementName=IntroScreen, Path=IsHandRaised}" Value="False">
                                    <DataTrigger.EnterActions>
                                        <BeginStoryboard Storyboard="{StaticResource ShowContent}" />
                                    </DataTrigger.EnterActions>
                                    <DataTrigger.ExitActions>
                                        <BeginStoryboard Storyboard="{StaticResource HideContent}" />
                                    </DataTrigger.ExitActions>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                </Image>
            </Grid>
        </Viewbox>

        <local:HandVisualizer IsHitTestVisible="False" Hand="{Binding Path=Controller.ActiveHand, Source={x:Static Application.Current}}" >
            <local:HandVisualizer.Style>
                <Style TargetType="{x:Type local:HandVisualizer}">
                    <Setter Property="Opacity" Value="0" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=IntroScreen, Path=IsHandRaised}" Value="True">
                            <DataTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource ShowContent}" />
                            </DataTrigger.EnterActions>
                            <DataTrigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HideContent}" />
                            </DataTrigger.ExitActions>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </local:HandVisualizer.Style>
        </local:HandVisualizer>
    </Grid>
</Window>